import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { ExtModal } from 'suid';
import { constants } from '@/utils';
import FormModal from './FormModal';

const { PRICE_MANGER_ACTION } = constants;
class ViewModal extends PureComponent {
  static formModalRef;

  static propTypes = {
    onCloseModal: PropTypes.func,
    currentData: PropTypes.object,
  };

  handlerFormModalRef = ref => {
    this.formModalRef = ref;
  };

  handlerCloseModal = () => {
    const { onCloseModal } = this.props;
    onCloseModal();
  };

  render() {
    const { currentData } = this.props;
    return (
      <ExtModal
        title="详情"
        closable={false}
        keyboard={false}
        visible
        destroyOnClose
        onCancel={this.handlerCloseModal}
        width={1000}
        onOk={this.handlerCloseModal}
      >
        <FormModal
          onFormModalRef={this.handlerFormModalRef}
          action={PRICE_MANGER_ACTION.VIEW}
          currentData={currentData}
        />
      </ExtModal>
    );
  }
}
export default ViewModal;
